/**
 * Created by jiabin.yu on 2018/9/22.
 */
import '/lib/router.js';

Router.route('/Home', function () {
    this.response.setHeader('access-control-allow-origin','*');
    var req = this.request.query;
    var res = this.response;
    var phone=req.phone;

    var Phone=Userinfo.findOne({ phone:phone});
    if(req.username && req.school && req.phone && req.num){
        if(Phone){
            res.end(Phone.phone+" 这个手机号已提交");
        }else{
            Meteor.call('Userinfo_op',{
                username:req.username,
                school:req.school,
                phone:req.phone,
                num:req.num,
                time:new Date()
            },(err,result)=>{
                if(!err){
                    if(result===1){
                        res.end("提交成功");
                    }else {
                        res.end("提交失败");
                    }
                }else {
                    res.end("提交失败");
                }
            })
        }
    }

}, {where: 'server'});



Router.route('/Result',
    {
        name:'Result',
        layoutTemplate:'',
        action:function(){
            this.render('Result');
        }
    });

Router.configure({layoutTemplate:'noLayout'});